package com.chebaohui.iqs.service.impl.deal.union.sdk;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取properties配置文件
 * 
 * @author xielonghai
 *
 */
public class ReadProperties {

	/**根据路径读取配置文件
	 * @param paths
	 * @return
	 */
	public static Properties getPropertiesFromPath(String paths) {
		LogUtil.writeLog("从路径读取配置文件: " + paths);
		File file = new File(paths);
		Properties properties = null;
		InputStream in = null;
		if (file.exists()) {
			try {
				in = new FileInputStream(file);
				properties = new Properties();
				properties.load(in);
			} catch (FileNotFoundException e) {
				LogUtil.writeErrorLog(e.getMessage(), e);
			} catch (IOException e) {
				LogUtil.writeErrorLog(e.getMessage(), e);
			} finally {
				if (null != in) {
					try {
						in.close();
					} catch (IOException e) {
						LogUtil.writeErrorLog(e.getMessage(), e);
					}
				}
			}
		} else {
			// 由于此时可能还没有完成LOG的加载，因此采用标准输出来打印日志信息
			LogUtil.writeErrorLog(paths + "不存在,加载参数失败");
		}
		return properties;
	}
}

